import useMessage from "@/hooks/useMessage";
import { updateLeaveWord } from "@/redux/modules/leaveWord/action";
import { Form, Button, Input } from "antd";
import React from "react";

interface PropsType {
	data: any;
	onComfirm?: () => void;
}

const LeaveWordEdit: React.FC<PropsType> = props => {
	const { contextHolder, success } = useMessage();

	const { data, onComfirm } = props;

	const onFinish = async (values: any) => {
		updateLeaveWord(values, data.id);
		onComfirm && onComfirm();
		success("修改成功");
	};

	return (
		<div>
			{contextHolder}
			<Form labelCol={{ span: 4 }} wrapperCol={{ span: 16 }} layout="horizontal" onFinish={onFinish}>
				<Form.Item label="内容" rules={[{ required: true }]} name="content">
					<Input.TextArea rows={4} />
				</Form.Item>
				<Form.Item wrapperCol={{ offset: 4 }}>
					<Button htmlType="submit" type="primary">
						提交
					</Button>
				</Form.Item>
			</Form>
		</div>
	);
};

export default LeaveWordEdit;
